ci: add workflow to regenerate models from OpenAPI spec#694
ci: add workflow to regenerate models from OpenAPI spec#694
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #694 +/- ##
==========================================
- Coverage 94.80% 94.68% -0.12%
==========================================
Files 45 45
Lines 4404 4403 -1
==========================================
- Hits 4175 4169 -6
- Misses 229 234 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a91f4ee to
3c43378
Compare
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a manually triggered GitHub Actions workflow to regenerate this repo’s generated Pydantic models from an OpenAPI spec produced in an apify/apify-docs PR, and open/update a PR with the updated src/apify_client/_models.py.
Changes:
- Introduces a
workflow_dispatchworkflow that checks outapify/apify-docsat a provided commit SHA and builds the bundled OpenAPI JSON. - Runs model generation via
datamodel-codegen, detects changes, and creates/updates a PR in this repo. - Posts a cross-repo comment back to the originating
apify-docsPR with the created/updated PR link (and a failure comment on error).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
This should follow the conventions (manual_regenerate_models.yaml)
| - name: Configure git | ||
| if: steps.changes.outputs.changed == 'true' | ||
| run: | | ||
| git config user.name "apify-service-account" | ||
| git config user.email "apify-service-account@users.noreply.github.com" | ||
|
|
||
| - name: Create or update PR | ||
| if: steps.changes.outputs.changed == 'true' | ||
| id: pr | ||
| env: | ||
| GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} | ||
| run: | | ||
| BRANCH="update-models-docs-pr-${DOCS_PR_NUMBER}" | ||
| DOCS_PR_URL="https://github.com/apify/apify-docs/pull/${DOCS_PR_NUMBER}" | ||
| TITLE="[TODO]: update generated models from apify-docs PR #${DOCS_PR_NUMBER}" | ||
|
|
||
| # -B creates the branch or resets it if it already exists (re-runs for the same docs PR). | ||
| git checkout -B "$BRANCH" | ||
| git add src/apify_client/_models.py | ||
| git commit -m "$TITLE" | ||
| git push --force origin "$BRANCH" | ||
|
|
||
| EXISTING_PR=$(gh pr list --head "$BRANCH" --json url --jq '.[0].url' 2>/dev/null || true) | ||
|
|
||
| if [[ -n "$EXISTING_PR" ]]; then | ||
| echo "PR already exists: $EXISTING_PR" | ||
| echo "pr_url=$EXISTING_PR" >> "$GITHUB_OUTPUT" | ||
| echo "created=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| BODY=$(cat <<EOF | ||
| This PR updates the auto-generated Pydantic models based on OpenAPI specification changes in [apify-docs PR #${DOCS_PR_NUMBER}](${DOCS_PR_URL}). | ||
|
|
||
| ## Changes | ||
|
|
||
| - Regenerated \`src/apify_client/_models.py\` using \`datamodel-codegen\` | ||
|
|
||
| ## Source | ||
|
|
||
| - apify-docs PR: ${DOCS_PR_URL} | ||
| EOF | ||
| ) | ||
|
|
||
| PR_URL=$(gh pr create \ | ||
| --title "$TITLE" \ | ||
| --body "$BODY" \ | ||
| --head "$BRANCH" \ | ||
| --base master) | ||
| echo "Created PR: $PR_URL" |
There was a problem hiding this comment.
These steps should use the commonly used reusable actions (add-and-commit and so on)
janbuchar
left a comment
There was a problem hiding this comment.
Consider my comments non-blocking, merge as you see fit.
Summary
workflow_dispatchworkflow that regenerates Pydantic models from anapify-docsPR's OpenAPI specdatamodel-codegen, and opens a PR if models changedapify-docsPR with a linkIssues
Context